home *** CD-ROM | disk | FTP | other *** search
- /********************************************
- * Decode Plus OSAX - by Jon Wiederspan 11/22/94
- * Based on DecodeURL by Chuck Shotton.
- * This code, the OSAX, and all of its constituent parts are hereby
- * placed in the public domain.
- *
- * This code converts "+" to spaces in text passed to it.
- *
- * This code was written using Think C. It should be build as a 68k
- * code resource to avoid problems. The code resource type is 'osax'
- * and its resource ID MUST match the event class and code.
- * For this event the name is "AEVTaevtdPls", indicating that this is
- * an AppleEvent, class aevt, code dPls.
- *********************************************/
-
- #include <AppleEvents.h>
-
- /*********************************************/
-
- pascal OSErr main( AppleEvent *theAEEvent,
- AppleEvent *theReply,
- long *theRefCon)
-
- {
- /* variables */
- OSErr theErr = noErr;
- DescType typeCode;
- Size sizeOfParam,
- actualSize;
- char *url;
- int i;
- unsigned char bite;
-
- theErr = AESizeOfParam( theAEEvent,
- keyDirectObject,
- &typeCode,
- &sizeOfParam);
-
- if (theErr != noErr){
- return theErr;
- }
- else{
- /*try converting lots of types of strings into something we can use*/
- if ((typeCode == typeChar) || (typeCode == typeStyledText) ||
- (typeCode == typeIntlText)) {
-
- /*Make a place to store the parameter, then get it.*/
- if (url = (char *) NewPtr (sizeOfParam+2)) {
- theErr = AEGetParamPtr(theAEEvent, keyDirectObject, typeChar,
- &typeCode, (Ptr) url,
- sizeOfParam+1, &actualSize);
-
- if(theErr == noErr) {
- /* 'C' string has a null as last char */
- url [actualSize] = '\0';
- i=0;
-
- /*decode the %xx encodings*/
- while ( url[i] ) {
- while ( url[i] ) {
- /* This is the only line I changed from DecodeURL */
- if (url [i]=='+') {
- url [i] = ' ';
- }
- i++;
- }
- }
- }
- /*return the result of any processing to the caller*/
- if (theReply->descriptorType != typeNull)
- theErr = AEPutParamPtr(theReply, keyDirectObject, typeChar,
- url, actualSize );
- DisposPtr (url);
- }
- else return errAEEventNotHandled;
- }
- else // Wasn't a string so bail
- return errAEEventNotHandled;
- }
-
- return theErr;
- }
-